if (typeof xdi8Transcriber === "undefined") await SoulLS.loadScript("https://cdn.jsdelivr.net/npm/xdi8-transcriber")
window.h2x ??= new xdi8Transcriber.HanziToXdi8Transcriber()
SoulLS.$out.style.font = "1em Fairfax HD XdPUA"
var xxx = x => xdi8Transcriber.chatToXdPUA("^" + x)
;(SoulLS.$text.oninput = () => {
  SoulLS.out = h2x.transcribe(SoulLS.text).map(s => {
    if (typeof s === "string") return s
    if (Array.isArray(s)) s = s.filter(s => !s.legacy)
    if (s.length === 1) return s[0].content.map(s => xxx(s.v)).join("")
    if (Array.isArray(s)) return "[" + s.map(s => s.content.map(s => xxx(s.v)).join("")).join("|") + "]"
    return xxx(s.v)
  }).join("")
})()